#-*- utf-8 -*-
import os
import os.path

project_name = "go_template"
# this folder is custom
rootdir = "./"
for parent, dirnames, filenames in os.walk(rootdir):
    for filename in filenames:
        suffix = os.path.splitext(filename)[1]
        if suffix is not in [".go", '.py'] or 'vendor' in parent:
            continue
        print("handle filename : ", filename)

        filepath = os.path.join(parent, filename)
        print("filepath : ", filepath)
        with open(filepath, "r+") as f:
            lines = f.readlines()
            print(lines)
            for index, line in enumerate(lines):
                lines[index] = line.replace("go_template", project_name)
                print(lines)
            f.seek(0, 0)
            f.writelines(lines)